package com.kaver.sso.web.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.kaver.sso.utils.CheckUtil;

/**
 * 参数校验切面
 * 
 * @author: guopeng
 * @title 参数校验切面
 */
@Aspect
@Component
@Order(10)
public class ParamValidateAspect {

    @Pointcut("execution(* com.kaver.sso.web.controller.rest..*.*(..))")
    private void aspect() {}

    @Around("aspect()")
    public Object around(JoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs();
        if (args != null && args.length > 0) {
            for (Object param : args) {
                CheckUtil.checkRequest(param);
            }
        }
        return ((ProceedingJoinPoint)joinPoint).proceed();
    }

}
